package View;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class GUI{
	/**
	 * 
	 */
	private static GUI gui = null;

	/**
	 * 
	 */
	private static JFrame frame = null;
	
	/** returns the one instance of the GUI class
	 * @return
	 */
	public static GUI getInstance(){
		if(gui == null){
			gui = new GUI();
			frame = new JFrame();
			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		}

		return gui;
	}
	
	public void setVisible(boolean val){
		frame.setVisible(val);
	}
	
	/** Adds a JPanel to the GUI frame
	 * 
	 * @param panel panel to add
	 * @param width width of the panel
	 * @param height height of the panel
	 */
	@SuppressWarnings("static-access")
	public void setContentPane(JPanel panel, int width, int height){
		gui.frame.setContentPane(panel);
		gui.frame.setResizable(true);
		gui.frame.setSize(new Dimension(width, height));
		gui.frame.setVisible(true);
	}
	
	public void closeWindow(){
		System.exit(1);
	}
	
	public String toString(){
		return super.toString();
	}
}
